package com.shanzmoo.db.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.shanzmoo.base.bean.PageRespBase;
import com.shanzmoo.base.bean.SResponse;
import com.shanzmoo.db.product.entity.ProductBrandEntity;
import com.shanzmoo.db.product.entity.vo.BrandQueryVO;
import com.shanzmoo.db.product.mapper.ProductBrandMapper;
import com.shanzmoo.db.product.service.IProductBrandService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 商品品牌 服务实现类
 * </p>
 *
 * @author Xueqz
 * @since 2020-12-06
 */
@Service
public class ProductBrandServiceImpl extends ServiceImpl<ProductBrandMapper, ProductBrandEntity> implements IProductBrandService {

    @Override
    public SResponse<PageRespBase<ProductBrandEntity>> getBrandList(BrandQueryVO brandQueryVO) {
        // 开启分页
        Page page = PageHelper.startPage(brandQueryVO.getPageNum(), brandQueryVO.getPageSize());
        //获取信息 -- start
        List<ProductBrandEntity> productBrandEntityList = getBrandListMethod(brandQueryVO);
        //获取信息 -- end
        PageRespBase<ProductBrandEntity> re = PageRespBase.create(page, productBrandEntityList);
        PageHelper.clearPage();
        return SResponse.ok(re);
    }
    @Override
    public List<ProductBrandEntity> getBrandListMethod(BrandQueryVO brandQueryVO){
        return baseMapper.selectList(new QueryWrapper<ProductBrandEntity>()
                .eq("deleted", false));
    }
}
